package com.lam.common.base.domain.tree;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import com.lam.common.components.dict.model.DictConvertible;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonInclude;

public abstract class BaseTree<T> implements DictConvertible{
	
	/** 子元素 */
	@TableField(exist = false)
	@JsonInclude(JsonInclude.Include.NON_EMPTY)
	protected List<T> children;

	/** 元素在树中的深度 */
	@TableField(exist = false)
	protected int elementDeep = 0;

	public abstract String getId();

	public abstract String getParentId();
	
	public abstract BigDecimal getSortNo();

	public void addChild(T t) {
		if(children == null) {
			children = new ArrayList<>();
		}
		children.add(t);
	}
	
	public List<T> getChildren() {
		return children;
	}

	public void setChildren(List<T> children) {
		this.children = children;
	}
	
	public int getElementDeep() {
		return elementDeep;
	}

	public void setElementDeep(int elementDeep) {
		this.elementDeep = elementDeep;
	}

}
